package com.srzk.youthleagueback.mapper;

import com.srzk.youthleagueback.pojo.Meeting;
import com.srzk.youthleagueback.pojo.ShowPlat;
import com.srzk.youthleagueback.pojo.SocialPractice;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
@Mapper
@Repository
public interface SocialPracticeMapper {

    @InsertProvider(value = SocialPracticeProvider.class, method = "insertSocialPractice")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert(SocialPractice record);

    @Select("SELECT * FROM social_practice WHERE user = #{user} AND year = #{year}")
    List<SocialPractice> selectByPrimaryKeyList(@Param("user") String user, @Param("year") String year);

    @Select("SELECT * FROM social_practice WHERE id = #{id} AND user = #{user} AND year = #{year}")
    SocialPractice selectByPrimaryKey(@Param("id") Long id, @Param("user") String user, @Param("year") String year);

    @UpdateProvider(value = SocialPracticeProvider.class, method = "updateSocialPractice")
    int updateByPrimaryKey(SocialPractice record);

    @Select("SELECT * FROM social_practice WHERE year = #{year}")
    List<SocialPractice> selectByGrade(@Param("year")String year);

    @Select("SELECT * FROM social_practice WHERE user = #{user}")
    List<SocialPractice> selectAll(@Param("user")String user);

    @Delete("DELETE FROM social_practice WHERE user = #{user} AND year = #{year} AND id = #{id}")
    int deleteByUserAndYearAndTypeAndId(@Param("user") String user, @Param("year") String year, @Param("id") Long id);
}